/*
 * InnerClassesAttribPane.java
 *
 * Created on January 27, 2002, 5:18 PM
 *
 * Modification Log:
 * 1.00   27th Jan 2002   Tanmay   Original version.
 *-----------------------------------------------------------------------------------------
 *       10th Sep 2003   Tanmay   Moved to SourceForge (http://classeditor.sourceforge.net)
 *-----------------------------------------------------------------------------------------
 */

package gui.attributes;

import classfile.*;
import classfile.attributes.Attribute;
import classfile.attributes.InnerClassesAttribute;
import classfile.attributes.InnerClassInfo;

import javax.swing.DefaultListModel;

/**
 * Copyright (C) 2002-2003  Tanmay K. Mohapatra
 * <br>
 *
 * @author 	Tanmay K. Mohapatra
 * @version     1.00, 27th January, 2002
 */
public class InnerClassesAttribPane extends javax.swing.JPanel implements AttribDisplay {

    private InnerClassesAttribute attribute;
    private ConstantPool constPool;
    private boolean bModifyMode;
    
    /** Creates new form InnerClassesAttribPane */
    public InnerClassesAttribPane(boolean bModifyMode) {
        this.bModifyMode = bModifyMode;
        
        initComponents();
    }

    public void setInput(Attribute attribute, ConstantPool constPool) {
        this.attribute = (InnerClassesAttribute)attribute;
        this.constPool = constPool;
        
        int iNumClasses = this.attribute.getNumClasses();
        lblNumInnerClasses.setText(Integer.toString(iNumClasses));
        DefaultListModel listModel = new DefaultListModel();
        for(int iIndex=0; iIndex < iNumClasses; iIndex++)
        {
            InnerClassInfo thisInfo = this.attribute.getInnerClassInfo(iIndex);
            listModel.addElement(thisInfo);
        }
        this.lstInnerClasses.setModel(listModel);        
    }    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        jLabel1 = new javax.swing.JLabel();
        lblNumInnerClasses = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        lstInnerClasses = new javax.swing.JList();
        
        setLayout(new java.awt.GridBagLayout());
        java.awt.GridBagConstraints gridBagConstraints2;
        
        jLabel1.setText("Number of Inner Classes");
        gridBagConstraints2 = new java.awt.GridBagConstraints();
        gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints2.insets = new java.awt.Insets(10, 10, 0, 0);
        gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
        add(jLabel1, gridBagConstraints2);
        
        gridBagConstraints2 = new java.awt.GridBagConstraints();
        gridBagConstraints2.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints2.insets = new java.awt.Insets(10, 10, 0, 10);
        gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints2.weightx = 1.0;
        add(lblNumInnerClasses, gridBagConstraints2);
        
        jScrollPane1.setViewportView(lstInnerClasses);
        
        gridBagConstraints2 = new java.awt.GridBagConstraints();
        gridBagConstraints2.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints2.insets = new java.awt.Insets(10, 10, 10, 10);
        gridBagConstraints2.weightx = 1.0;
        gridBagConstraints2.weighty = 1.0;
        add(jScrollPane1, gridBagConstraints2);
        
    }//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel lblNumInnerClasses;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JList lstInnerClasses;
    // End of variables declaration//GEN-END:variables

}
